pkgname=wm-scripts-intothegnu-git
pkgver=1.0.r0.g8ae32f5
pkgrel=1
license=(GPL)
arch=('any')
groups=('intothegnu-config')
depends=('dunst')
optdepends=('pulseaudio: volume and mute notification' 'pipewire-pulse: volume and mute notification' 'imagemagick: screenshot' 'scrot: screenshot' 'newsboat: newsboat script' 'xbacklight: backlight script' 'ffmpeg: record script')
makedepends=(git)
source=(git+https://notabug.org/BezierQuadratic/wm-scripts.git)
sha256sums=('SKIP')

pkgver(){
	cd wm-scripts
	git describe --long --tags | sed 's/-/.r/;s/-/./'
}

package(){
	cd $srcdir/wm-scripts
	mkdir -p $pkgdir/usr/bin
	mkdir -p $pkgdir/usr/share/licenses/wm-scripts-intothegnu
	cp LICENSE $pkgdir/usr/share/licenses/wm-scripts-intothegnu
	sourcefiles="$(find . -iname '*.sh')"
	destfiles="${sourcefiles//.sh/}"
	current_line=1
	tot_lines="$(echo "$sourcefiles" | wc -l)"
	while [ "$current_line" -le "$tot_lines" ]; do
		install -m 755 "$(echo "$sourcefiles" | sed -n "$current_line"p)" $pkgdir/usr/bin/"$(echo "$destfiles" | sed -n "$current_line"p)"
		current_line=$((current_line + 1))
	done
}
